<template>
  <div class="category">
        <category-header></category-header>
        <category-content :goodsList="goodsList"></category-content>
        <category-nav :navList="navList"></category-nav>
  </div>
</template>

<script>
import axios from 'axios'
import CategoryHeader from './components/CategoryHeader'
import CategoryContent from './components/CategoryContent'
import CategoryNav from './components/CategoryNav'
export default {
  name: 'Category',
  data () {
    return {
        goodsList:[],
        navList:[]
    }
  },
  components:{
    CategoryHeader,
    CategoryContent,
    CategoryNav 
  },
  methods:{
      tab (index){
          this.num = index
      }
  },
  mounted(){
    this.getHomeInfo()
  },
  methods:{
    getHomeInfo(){
        // axios返回的结果是一个promise对象
        axios.get('/shopping_mall/index.php/Home/Category/index').then(
        // 注意：这里绝对不可以写成this.getHomeInfoSucc（），否则请求的结果会是undefined
        this.getHomeInfoSucc
      )
    },
    getHomeInfoSucc(res){
        // console.log(res)
        res = res.data 
        // console.log(res)
        if(res.ret && res.data){
          this.goodsList = res.data.goodsList
          this.navList = res.data.navList
        }
    }
  }
}
</script>

<style lang="stylus" scoped>
.category
    background-color #efefef
</style>
